package net.oschina.bilbodai.common.beanutil.bean.creator;

import net.oschina.bilbodai.common.beanutil.bean.code.IPropertyCodeApplier;
import net.oschina.bilbodai.common.beanutil.bean.code.ItCollectToItCollectApplier;
import net.oschina.bilbodai.common.beanutil.bean.core.PropertyDumpInfo;
import net.oschina.bilbodai.common.beanutil.bean.core.PropertyInfo;
import net.oschina.bilbodai.common.beanutil.exception.PropertyDumpException;

import java.util.List;

/**
 * @author daimao  Date: 16/5/30 Time: 上午11:34
 * @version $Id$
 */
public enum ItCollectToItCollectCreator implements IPropertyCodeApplierCreator{
    INSTANCE;

    @Override
    public IPropertyCodeApplier create(PropertyDumpInfo dumpInfo, PropertyInfo sourceInfo, PropertyInfo targetInfo) {
        if (sourceInfo.getFieldType() == null) {
            throw new PropertyDumpException(sourceInfo + "s FieldType can't be null in Single Mode");
        }
        if (targetInfo.getFieldType() == null) {
            throw new PropertyDumpException(targetInfo + "s FieldType can't be null in Single Mode");
        }

        CodeApplierCreators.checkSorted(dumpInfo);

        return new ItCollectToItCollectApplier(dumpInfo);
    }

}